﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// Definition of a control ID property which needs to be resolved to ClientID when rendered.
	/// </summary>
	public class ControlIdPropertyDefinition : PropertyDefinition<string>
	{
		#region PUBLIC
		#region INIT
		/// <summary>
		/// Ctor.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="shortName"></param>
		/// <param name="defaultValue"></param>
		public ControlIdPropertyDefinition(string name, string shortName, string defaultValue)
			: base(name, shortName, defaultValue)
		{
		}
		#endregion
		#region EVENTS
		#endregion
		#region PROPS
		#endregion
		#region METHODS
		#endregion
		#endregion
		#region INTERNAL
		#region CONST/STATIC
		#endregion
		#region VARS
		#endregion
		#region PROPS
		#endregion
		#region METHODS
		#region INIT
		#endregion
		#region DATA
		/// <summary>
		/// Serializes the value of this property for the specified control to the specified <see cref="TA.JSON.JsonWriter"/>.
		/// </summary>
		/// <param name="control"></param>
		/// <param name="jw"></param>
		protected override void DoSerializeValue(TControl control, TA.JSON.JsonWriter jw)
		{
			Control c = control.FindControlGlobal(this.GetValue(control));
			if (c == null)
				jw.Null();
			else
				jw.Value(c.ClientID);

		}
		#endregion
		#region HANDLERS
		#endregion
		#endregion
		#endregion				
				
	}
}
